home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4998 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  75 lines

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: READ THIS!!!!!!!!!!!
  5. Date: 02 Feb 1996 01:18:45 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Feb1201845@g7240065.bridge.bst.bls.com>
  8. References: <4em5fs$a86@ixnews4.ix.netcom.com>
  9.     <4er65q$d8v@usenet1.sjc.in.sel.sony.com>
  10. NNTP-Posting-Host: bstfirewall.bst.bls.com
  11. In-reply-to: Victor Marilao's message of 1 Feb 1996 20:00:58 GMT
  12.  
  13. In article <4er65q$d8v@usenet1.sjc.in.sel.sony.com> Victor Marilao <victorm@sec.sel.sony.com> writes:
  14.  
  15. : jeremyx@ix.netcom.com(Jeremy Johnston ) wrote:
  16. :> 
  17. :>   ok....now that I have your attention i need some help.
  18. :> I can't get the following command to work & the compiler says that the
  19. :> constant has too many characters.
  20. :> 
  21. :>   char dos;
  22. :>     if(dos=='dir')
  23. :>     goto b;
  24. :> 
  25. :> How can i do this to get it to work? please help,I know you can.
  26. :> 
  27. :> 
  28.  
  29. : Try this:
  30.  
  31. : #include "stdio.h"
  32. : #include "string.h"
  33.  
  34. : main()
  35. : {
  36. :     char *dos;
  37. : //  strcpy(dos, "dir");  // Uncomment to test for a valid 
  38. : match
  39.  
  40. Uncomment this for some strange behaviour.
  41.  
  42. :     if (strcmp(dos, "dir") == 0)
  43. :       printf("Its a match");
  44. : }
  45.  
  46. : E-mail me if you need an explanation.
  47.  
  48. Yes I need an explanation on why you think this will work.
  49. The next question from this person will be:
  50.  
  51.   #include "string.h"
  52.  
  53.   int
  54.   main(void)
  55.   {
  56.       char* str;
  57.       strcpy(str, "SomeString");
  58.  
  59.       return 0;
  60.   }
  61.  
  62.   Why does this crash (my operating system - it was in dos ;') ?
  63.  
  64. Because you didn't allocate space for str;
  65.  
  66. Regards
  67.  
  68.    -A.
  69.  
  70.  
  71.  
  72.  
  73. -- 
  74. | A.Champion                |
  75.